package com.oolatina.fragments;


import org.json.JSONObject;

import com.oolatina.R;
import com.oolatina.RadioView;
import com.oolatina.SCAudioPlayer;
import com.oolatina.SCButton;
import com.oolatina.SCImage;
import com.oolatina.SCItunesPartner;
import com.oolatina.SCLabel;
import com.oolatina.SCNetwork;
import com.oolatina.activity.MainActivity;
import com.oolatina.activity.YoutubeView;
import com.oolatina.adapters.VideoGridAdapter;

import android.os.Bundle;
import android.content.Context;
import android.content.Intent;
import android.support.v4.widget.DrawerLayout;
import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.FrameLayout;
import android.widget.GridView;
import android.widget.LinearLayout;

public class VideoFragment extends BaseFragment implements OnItemClickListener {


	private int[] videoIDs;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater,
	 * android.view.ViewGroup, android.os.Bundle)
	 */
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		mView = inflater.inflate(R.layout.fragment_videoview, null);
		videoIDs = mView.getContext().getResources().getIntArray(R.array.video_ids);
		GridView gridview = (GridView) mView.findViewById(R.id.gridview);
	    gridview.setAdapter(new VideoGridAdapter(mView.getContext()));
	    gridview.setOnItemClickListener(this);
//	    gridview.setOnItemClickListener(new OnItemClickListener() {
//	        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
//	            Toast.makeText(HelloGridView.this, "" + position, Toast.LENGTH_SHORT).show();
//	        }
//	    });
		
		
		return mView;
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
		int videoID = videoIDs[position];
		VideoListFragment frag = new VideoListFragment();
		Bundle args = new Bundle();
		args.putInt("DATA", videoID);
		frag.setArguments(args);
		((MainActivity) getActivity()).showNextScreen(frag);
		
	}
	
}
